﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class AccountTypeCls
    {
        public string AccountType;
        public string Description;
        public int TotalRole = 0;
    }


    public class AccountTypeParser
    {
        public static AccountTypeCls CreateInstance()
        {
            //tao 1 class trang....
            AccountTypeCls oAccountTypeCls = new AccountTypeCls();
            return oAccountTypeCls;
        }

        public static AccountTypeCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            AccountTypeCls oAccountTypeCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oAccountTypeCls;
        }


        public static AccountTypeCls ParseFromDataRow(DataRow dr)
        {
            AccountTypeCls OAccountTypeCls = new AccountTypeCls();
            OAccountTypeCls.AccountType = XmlUtility.GetString(dr, "AccountType", true);
            OAccountTypeCls.Description = XmlUtility.GetString(dr, "Description", true);
            OAccountTypeCls.TotalRole = XmlUtility.GetInt(dr,"TotalRole",true);

            return OAccountTypeCls;
        }

        public static AccountTypeCls[] ParseFromDataTable(DataTable dtTable)
        {
            AccountTypeCls[] AccountTypes = new AccountTypeCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                AccountTypes[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return AccountTypes;
        }
    }
}
